import request from '@/request'


export function getArticles(query,nickname, page) {
  return request({
    url: '/articles',
    method: 'post',
    data: {
      page: page.pageNumber,
      pageSize: page.pageSize,
      name: page.name,
      sort: page.sort,
      year: query.year,
      month: query.month,
      tagId: query.tagId,
      categoryId: query.categoryId,
      nickname: nickname,

    }
  })
}
export function getArticleAll(query) {
  return request({
    url: '/articles/listArticleAll',
    method: 'post',
    data: {
      page: query.pageNumber,
      pageSize: query.pageSize,
      title: query.title,
      author: query.author,
    }
  })
}

export function getHotArtices() {
  return request({
    url: '/articles/hot',
    method: 'post'
  })
}

export function getNewArtices() {
  return request({
    url: '/articles/new',
    method: 'post'
  })
}
export function setHobby(form,token) {
  return request({
    url: `/hobby/setHobby/${token}`,
    method: 'post',
    data: {
      name: form.name,
      catoon: form.catoon,
      girl: form.girl,
      game: form.game,
      color: form.color,
    }
  })
}

export function getHobby(token) {
  return request({
    url: `/hobby/getHobby/${token}`,
    method: 'post'
  })
}

export function viewArticle(id) {
  return request({
    url: `/articles/view/${id}`,
    method: 'post'
  })
}
export function deleteArticle(id) {
  return request({
    url: `/articles/deleteArticle/${id}`,
    method: 'post'
  })
}

export function getArticlesByCategory(id) {
  return request({
    url: `/articles/category/${id}`,
    method: 'post'
  })
}

export function getArticlesByTag(id) {
  return request({
    url: `/articles/tag/${id}`,
    method: 'post'
  })
}


export function publishArticle(article,token) {
  return request({
    headers: {'Authorization': token},
    url: '/articles/publish',
    method: 'post',
    data: article
  })
}

export function listArchives() {
  return request({
    url: '/articles/listArchives',
    method: 'post'
  })
}

export function getArticleById(id) {
  return request({
    url: `/articles/${id}`,
    method: 'post'
  })
}

export function getPVAndUV() {
  return request({
    url: `/visitornum`,
    method: 'get'
  })
}
